<div class="judul"><?php echo anchor("/info_perbandingan_nilai/",$title);?></div>
<?php
  $uri_segment = $this->uri->segment(3);
  if($uri_segment != "" && $uri_segment != "all"){
      $option = parsing_param2($uri_segment);
      $kelas = $option['kelas'];
      $mapel = $option['mapel'];
      $id_mapel = $option['idMapel'];
      $tahun_ajaran = $option['tahunAjaran'];
  }else{
      $kelas = "";
      $mapel = "";
      $id_mapel = "";
      $tahun_ajaran = "";
  }
?>
<script type="text/javascript">
  $(document).ready(function(){
      $('#mapel').autocomplete("<?php echo site_url('ajax_target')."/searchMataPelajaranByKelas" ?>",
            {
                extraParams:{
                  id_kelas: function(){
                      return $('#kelas').val();
                  }  
                },
                parse: function(data){
                    var parsed = [];
                    for (var i=0; i < data.length; i++) {
                        parsed[i] = {
                            data: data[i],
                            value: data[i].batch // nama field yang dicari
                        };
                    }
                    return parsed;
                },
                formatItem: function(data,i,max){
                    return '<div class=result>'+data.nama+'<br>Kelas: '+data.kelas+" "+data.tingkat_pendidikan+'</div>';
                },
                width: 300, // panjang tampilan pencarian autocomplete yang akan muncul di bawah textbox pencarian
                dataType: 'json' // tipe data yang diterima oleh library ini disetup sebagai JSON
            }).result(
            function(event,data,formated){
               $(this).attr('value',data.nama);
               $('#id_mapel').val(data.id);
            });
  })
</script>
<div class="data-input">
    <fieldset>
        <legend><?php echo "$formTitle";?></legend>
        <?php
          echo form_open('info_perbandingan_nilai/search');
        ?>
        <label>Kelas</label>
        <select name="kelas" id="kelas">
            <option value="">Pilih kelas</option>
            <?php
                foreach ($listKelas as $row){
            ?>
            <option value="<?php echo $row['id'];?>" <?php if($kelas == $row['id']) echo "selected='selected'";?>><?php echo $row['nama']." ".$row['tingkat_pendidikan'];?></option>
            <?php
                }
            ?>
        </select>
        <label>Mata Pelajaran</label><?php echo form_input('mapel', $mapel, 'id=mapel');?>
        <input type="hidden" name="id_mapel" id="id_mapel" value="<?php echo "$id_mapel";?>"/>
        <label>Tahun Ajaran</label>
        <select name="tahun_ajaran" id="tahun_ajaran">
            <option value="all">Pilih tahun ajaran</option>
            <?php
                foreach ($listTahunAjaran as $rows){
            ?>
            <option value="<?php echo $rows['id'];?>" <?php if($rows['id'] == $tahun_ajaran) echo "selected='selected'";?>><?php echo $rows['nama']." ".$rows['semester']?></option>
            <?php
                }
            ?>  
        </select>
        <fieldset class="input-process">
        <?php
          echo form_hidden("Apply",TRUE);
          echo form_hidden("url", $searchLink);
          echo form_submit('add', 'Cari', 'class=button id=submit style=margin-right:2px');
          echo form_button('Batal', 'Batal', 'class=button onClick='."javascript:location.href='".base_url()."index.php/info_perbandingan_nilai/'".'');
          echo form_close();
        ?>
        </fieldset>
    </fieldset>
</div>
<fieldset>
<?php
  if($option['Apply'] == TRUE){
?>
<?php
  if(file_exists($graph)){
?>
<center>
  <img src="<?php echo base_url().$graph;?>" />
</center>  
<?php
  }
?> 
<div class="data-list">
    <table class="tabel" style="width: 100%">
        <tr>
            <th>No</th>
            <th>Adik Asuh</th>
            <th>KKM</th>
            <th>Nilai Angka</th>
            <th>Nilai Terbilang</th>
            <th>Deskripsi Kemajuan Belajar</th>
        </tr>
        <?php
        $no = 1;
        foreach ($listPerbandinganNilai as $row){
        ?>
        <tr class="<?php echo ($no%2)?"even":"odd";?>">
            <td style="text-align:center"><?php echo $no++;?></td>
            <td><?php echo $row['adik_asuh'];?></td>
            <td><?php echo $row['kkm'];?></td>
            <td><?php echo $row['nilai_angka'];?></td>
            <td><?php echo $row['nilai_terbilang'];?></td>
            <td><?php echo $row['deskripsi_kemajuan_belajar'];?></td>
        </tr>
        <?php
        }
        ?>
    </table>
</div>
<?php
  }else{
      echo "<span class='tips'>Silahkan menggunakan opsi pencarian di atas</span>";
  }
?>
</fieldset>